package com.mall507.fivepeaks.activity.mine;

import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.hzh.frame.comn.annotation.ViewInject;
import com.hzh.frame.core.BaseSP;
import com.hzh.frame.ui.activity.BaseUI;
import com.hzh.frame.util.CloseAppUtil;
import com.hzh.frame.widget.xdialog.XDialog2Button;
import com.mall507.comn.model.User;
import com.mall507.comn.tools.UserTools;
import com.mall507.fivepeaks.R;

@Route(path = "/mine/SettingUI")
public class SettingUI extends BaseUI implements View.OnClickListener {
    @ViewInject(R.id.editData) LinearLayout editData;
    @ViewInject(R.id.safe) LinearLayout safe;
    @ViewInject(R.id.quit) LinearLayout quit;
    
    @Override
    protected void onCreateBase() {
        setContentView(R.layout.ui_mine_setting);
        getTitleView().setContent("设置");
        editData.setOnClickListener(this);
        safe.setOnClickListener(this);
        quit.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.editData:
                ARouter.getInstance().build("/mine/SettingEditDataUI").navigation(); //编辑资料
                break;
            case R.id.safe:
                ARouter.getInstance().build("/mine/SettingSafeUI").navigation(); //账号与安全
                break;
            case R.id.quit:
                new XDialog2Button(SettingUI.this).setMsg("你确定要退出登录吗?").setCallback(new XDialog2Button.XDialog2ButtonCallBack() {
                    @Override
                    public void confirm() {
//                        CloseAppUtil.restartLogin(SettingUI.this, "/login/login", User.class);
                        ARouter.getInstance().build("/login/login").navigation();
//                        ARouter.getInstance().build("/main/MainUI").with(getIntent().getExtras()).navigation();
                        BaseSP.getInstance().put("token","");
                        UserTools.getInstance().clear();
                        finish();
                    }
                    @Override
                    public void cancel() {}
                }).show();
                break;
        }
    }
}
